<?php
/**
 * 公告
 */

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

class Notice extends Api {
	protected $noNeedLogin = ['*'];
	
	/**
	 * 公告列表
	 */
	public function index() {
		$rows = Db::name('notice')
			->where(['status' => \app\admin\model\Notice::STATUS_SHOW])
			->order('create_time desc')
			->field('id, title, from_unixtime(create_time) as date')
			->select();
		
		$this->success('查询成功', $rows);
	}
	
	
	/**
	 * 详情
	 */
	public function detail() {
		$id = $this->request->post('id');
		!$id && $this->error('参数错误');
		
		$row = Db::name('notice')
			->where(['id' => $id, 'status' => \app\admin\model\Notice::STATUS_SHOW])
			->find();
		$this->success('查询成功', $row);
	}
}
